/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.config.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.hera.base.domain.BaseDomain;
import com.hera.base.util.DateUtil;

/**
 *
 * @author cmontes
 */
@Entity
public class Holiday extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @Column(name = "ID_HOLIDAY")
    private Long idHoliday;
    private String name;
    private String description;
    @Column(name = "HOLIDAY_START")
    @Temporal(TemporalType.TIMESTAMP)
    private Date holidayStart;
    @Column(name = "HOLIDAY_END")
    @Temporal(TemporalType.TIMESTAMP)
    private Date holidayEnd;
    @JoinColumn(name = "ID_CALENDAR", referencedColumnName = "ID_CALENDAR")
    @ManyToOne
    private Calendar calendar;
    
    
    
    @ManyToOne
    @JoinColumn(name="ID_MES")
    private ParameterDetail mes;
    @ManyToOne
    @JoinColumn(name="ID_TIPO")
    private ParameterDetail tipo;

    public Holiday() {
    }

    public Holiday(Long idHoliday) {
        this.idHoliday = idHoliday;
    }

    public Long getIdHoliday() {
        return idHoliday;
    }

    public void setIdHoliday(Long idHoliday) {
        this.idHoliday = idHoliday;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getHolidayStart() {
        return holidayStart;
    }

    public void setHolidayStart(Date holidayStart) {
        this.holidayStart = holidayStart;
    }

    public Date getHolidayEnd() {
        return holidayEnd;
    }

    public void setHolidayEnd(Date holidayEnd) {
        this.holidayEnd = holidayEnd;
    }

    public Calendar getCalendar() {
        return calendar;
    }

    public void setCalendar(Calendar calendar) {
        this.calendar = calendar;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idHoliday != null ? idHoliday.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof Holiday)) {
            return false;
        }
        Holiday other = (Holiday) object;
        if ((this.idHoliday == null && other.idHoliday != null) || (this.idHoliday != null && !this.idHoliday.equals(other.idHoliday))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.Holiday[ idHoliday=" + idHoliday + " ]";
    }

	public ParameterDetail getMes() {
		return mes;
	}

	public void setMes(ParameterDetail mes) {
		this.mes = mes;
	}

	public ParameterDetail getTipo() {
		return tipo;
	}

	public void setTipo(ParameterDetail tipo) {
		this.tipo = tipo;
	}
	
	
	public String getDays () {
		return  DateUtil.getFechaFormat(holidayStart,"dd")+" - "+DateUtil.getFechaFormat(holidayEnd,"dd");
				
	}
    
}
